define(
[],
function(){
    return {
        getName: function() {
            return "COMP - CRENDER UNIT"
        },

        create: function() {

            var _self = {
                init: function(bufPosUnit, bufIndUnit, pickUnit, bufVisibleUnit, centerPos) {
                    //Assign members
                    _bufPosUnit     = bufPosUnit;
                    _bufIndUnit     = bufIndUnit;
                    _pickUnit       = pickUnit;
                    _bufVisibleUnit = bufVisibleUnit;
                    _centerPos      = centerPos;

                    //Assign listener
                    _pickListeners  = [];
                    _pickUnit.addPickListener(_onPicked);

                    //Return myself
                    return _self;
                },

                getCenterPos: function() { return _centerPos; },

                getClass: function() { return _CLASS; },

                addPickListener: function(F_listener) {
                    _pickListeners.push(F_listener);
                },

                remPickListener: function(F_listener) {
                    _pickListeners.splice(_pickListeners.indexOf(F_listener),1);
                },

                setVisible: function(val) {
                    _bufVisibleUnit.changeAllData(val ? 1 : 0);
                },

                destroy: function() {
                    _bufPosUnit.destroy();
                    _bufIndUnit.destroy();
                    _pickUnit.destroy();
                }
            };

            var _bufPosUnit;
            var _bufIndUnit;
            var _pickUnit;
            var _bufVisibleUnit;
            var _pickListeners;
            var _centerPos;
            var _CLASS = this;

            function _onPicked() {
                for(var idx in _pickListeners)
                    _pickListeners[idx](_self);
            }

            return _self;
        }
    };
});